/*
 * mibItem.cpp
 *
 *  Created on: 2011-7-6
 *      Author: fufan
 */
#include "mibItem.h"
#include <QtAlgorithms>

MibItem::	MibItem(const QList<QVariant> &data, MibItem *parentItem)
{

		this->data = data;
		this->parentItem = parentItem;
		this->children.clear();
}

MibItem::	~MibItem()
{
		qDeleteAll(children);
}

MibItem* MibItem::parent() const
{

		return parentItem;
}

MibItem* MibItem::child(int index) const
{

		return children.at(index);
}

void MibItem::appendChild(MibItem *child)
{

	children.append(child);
}

int MibItem::childCount() const
{
	return children.count();
}

int MibItem::row()
{
		if(parentItem)
			return parentItem->children.indexOf(const_cast<MibItem *>(this));
		return 0;
}

QVariant MibItem::dataValue(int column) const
{
		return data.value(column);
}

QList<QVariant> MibItem::dataList() const
{
	 return data;
}
